package com.opal.model.easyui;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import java.util.Map;

/**
 * datagrid数据模型
 */
@JsonInclude(value = Include.NON_NULL)
public class DataGridColumn {

    public static final String EDITORTYPETEXT="text";
    public static final String EDITORTYPETEXTBOX="textbox";
    public static final String EDITORTYPENUMBERBOX="numberbox";
    public static final String EDITORTYPEDATABOX="datebox";
    public static final String EDITORTYPECOMBOBOX="combobox";
    public static final String EDITORTYPECOMBOTREE="combotree";

    private String title;               //列的标题文本。
    private String field;               //列的字段名
    private String width;              //列的宽度。如果未定义，则宽度会自动扩展以适应它的内容。没有定义宽度将会降低性能。
    private Integer rowspan;            //指定本单元格占据多少行，默认null
    private Integer colspan;            //指定本单元格占据多少列   默认null
    private String align;               //指示如何对齐该列的数据，值'left'、'right'、'center'。
    private String halign;               //指示如何对齐该列的头部，可能的值：'left'、'right'、'center'。若没有分配值和align一致
    private String sortable;            //设置为 true，则允许该列被排序。
    private String order;               //默认的排序顺序，只能用 'asc' 或 'desc'。
    private String resizable;            //设置为 true，则允许该列可调整尺寸。
    private String fixed;               //设置为 true，则当 'fitColumns' 设置为 true 时放置调整宽度。
    private String hidden;               //设置为 true，则隐藏该列
    private String checkbox;              //设置为 true，则显示复选框。复选框有固定宽度。
    private Edit editor;                  //列的标题文本。
    private String formatter;

    public DataGridColumn(){}

    public DataGridColumn(String title, String field){
        this.title=title;
        this.field=field;
    }

    public DataGridColumn(String title, String field, String width){
        this.title=title;
        this.field=field;
        this.width=width;
    }

    public DataGridColumn(String title, String field, String width, String hidden){
        this.title=title;
        this.field=field;
        this.width=width;
        this.hidden=hidden;
    }

    public String getFormatter() {
        return formatter;
    }

    public void setFormatter(String formatter) {
        this.formatter = formatter;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public Integer getRowspan() {
        return rowspan;
    }

    public void setRowspan(Integer rowspan) {
        this.rowspan = rowspan;
    }

    public Integer getColspan() {
        return colspan;
    }

    public void setColspan(Integer colspan) {
        this.colspan = colspan;
    }

    public String getAlign() {
        return align;
    }

    public void setAlign(String align) {
        this.align = align;
    }

    public String getHalign() {
        return halign;
    }

    public void setHalign(String halign) {
        this.halign = halign;
    }

    public String getSortable() {
        return sortable;
    }

    public void setSortable(String sortable) {
        this.sortable = sortable;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public String getResizable() {
        return resizable;
    }

    public void setResizable(String resizable) {
        this.resizable = resizable;
    }

    public String getFixed() {
        return fixed;
    }

    public void setFixed(String fixed) {
        this.fixed = fixed;
    }

    public String getHidden() {
        return hidden;
    }

    public void setHidden(String hidden) {
        this.hidden = hidden;
    }

    public String getCheckbox() {
        return checkbox;
    }

    public void setCheckbox(String checkbox) {
        this.checkbox = checkbox;
    }

    public Edit getEditor() {
        return editor;
    }

    public void setEditor(Edit editor) {
        this.editor = editor;
    }
// 内部类
public class Edit{
        private String type;            //编辑类型：值：text、textbox、checkbox、numberbox、validatebox、datebox、combobox、combotree。
        private Map<String,Object> options; //编辑类型对应的编辑器属性选项

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public Map<String, Object> getOptions() {
            return options;
        }

        public void setOptions(Map<String, Object> options) {
            this.options = options;
        }
    }
}
